/*
 * Jenny Ruppen 09-730-391
 * Sebastien Goldberg 08-914-855
 * Henry Raymond 08-928-061
 * Stefan Mussato 09-752-270
 */
 
package ch.uzh.ifi.sopra.gruppe9.game;

import com.jme3.scene.Node;


/**
 * Draws a box in the GUI.
 */
public class GuiBox extends Node {
	
	
	/**
	 * Offset of the coordinate system of this box.
	 */
	private GUI.Offset offset;
	
	
	/**
	 * Position of the box in the x axis. (Assuming the window has a width of 1024 pixel.)
	 */
	private int positionX;
	
	
	/**
	 * Position of the box in the y axis. (Assuming the window has a height of 768 pixel.)
	 */
	private int positionY;
	
	
	/**
	 * Width of the box. (Assuming the window has a width of 1024 pixel.)
	 */
	private int width;
	
	
	/**
	 * Height of the box. (Assuming the window has a height of 768 pixel.)
	 */
	private int height;
	
	
	/**
	 * Z-Index of the element. An element with a higher index will cover an element with a lower one.
	 */
	private int zIndex;
	
	
	/**
	 * Constructor
	 */
	public GuiBox(GUI.Offset offset, int positionX, int positionY, int width, int height, int zIndex) {
		this.offset = offset;
		this.positionX = positionX;
		this.positionY = positionY;
		this.width = width;
		this.height = height;
		this.zIndex = zIndex;
		
		GuiQuad cornerTopLeft = new GuiQuad();
		cornerTopLeft.setAbsolutePositionSize(-10, -10, 30, 30, 0);
		cornerTopLeft.setMaterial(MaterialManager.getGuiBox(), 0.0f, 0.0f, 0.33333f, 0.33333f);
		this.attachChild(cornerTopLeft.create());
		
		GuiQuad cornerTopRight = new GuiQuad();
		cornerTopRight.setAbsolutePositionSize(width - 20, -10, 30, 30, 0);
		cornerTopRight.setMaterial(MaterialManager.getGuiBox(), 0.66666f, 0.0f, 0.33333f, 0.33333f);
		this.attachChild(cornerTopRight.create());
		
		GuiQuad cornerBottomLeft = new GuiQuad();
		cornerBottomLeft.setAbsolutePositionSize(-10, height - 20, 30, 30, 0);
		cornerBottomLeft.setMaterial(MaterialManager.getGuiBox(), 0.0f, 0.66666f, 0.33333f, 0.33333f);
		this.attachChild(cornerBottomLeft.create());
		
		GuiQuad cornerBottomRight = new GuiQuad();
		cornerBottomRight.setAbsolutePositionSize(width - 20, height - 20, 30, 30, 0);
		cornerBottomRight.setMaterial(MaterialManager.getGuiBox(), 0.66666f, 0.66666f, 0.33333f, 0.33333f);
		this.attachChild(cornerBottomRight.create());
		
		GuiQuad cornerTopLine = new GuiQuad();
		cornerTopLine.setAbsolutePositionSize(20, -10, width - 40, 30, 0);
		cornerTopLine.setMaterial(MaterialManager.getGuiBox(), 0.33333f, 0.0f, 0.33333f, 0.33333f);
		this.attachChild(cornerTopLine.create());
		
		GuiQuad cornerBottomLine = new GuiQuad();
		cornerBottomLine.setAbsolutePositionSize(20, height - 20, width - 40, 30, 0);
		cornerBottomLine.setMaterial(MaterialManager.getGuiBox(), 0.33333f, 0.66666f, 0.33333f, 0.33333f);
		this.attachChild(cornerBottomLine.create());
		
		GuiQuad cornerLeftLine = new GuiQuad();
		cornerLeftLine.setAbsolutePositionSize(-10, 20, 30, height - 40, 0);
		cornerLeftLine.setMaterial(MaterialManager.getGuiBox(), 0.0f, 0.33333f, 0.33333f, 0.33333f);
		this.attachChild(cornerLeftLine.create());
		
		GuiQuad cornerRightLine = new GuiQuad();
		cornerRightLine.setAbsolutePositionSize(width - 20, 20, 30, height - 40, 0);
		cornerRightLine.setMaterial(MaterialManager.getGuiBox(), 0.66666f, 0.33333f, 0.33333f, 0.33333f);
		this.attachChild(cornerRightLine.create());
		
		this.setLocalTranslation(GUI.calculateX(offset, positionX), GUI.calculateY(offset, positionY), (float)zIndex);
	}


	public GUI.Offset getOffset() {
		return offset;
	}


	public int getPositionX() {
		return positionX;
	}


	public int getPositionY() {
		return positionY;
	}


	public int getWidth() {
		return width;
	}


	public int getHeight() {
		return height;
	}


	public int getZIndex() {
		return zIndex;
	}

}
